<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script type="text/javascript" src="dialog.js"></script>

<script type="text/javascript">
document.write ("<link href='../skin/" + config.Skin + "/dialog.css' type='text/css' rel='stylesheet'>");

var sAction = URLParams['action'] ;
var sTitle = "";
var color = "" ;
var oSelection;
var oControl;
var sRangeType;

switch (sAction) {
	case "forecolor":
		sTitle = lang["DlgSelCorForecolor"];
		oSelection = dialogArguments.eWebEditor.document.selection.createRange();
		color = oSelection.queryCommandValue("ForeColor");
		if (color) color = N2Color(color);
		break;
	case "backcolor":
		sTitle = lang["DlgSelCorBackcolor"];
		oSelection = dialogArguments.eWebEditor.document.selection.createRange();
		color = oSelection.queryCommandValue("BackColor");
		if (color) color = N2Color(color);
		break;
	case "bgcolor":
		sTitle = lang["DlgSelCorBgcolor"];
		oSelection = dialogArguments.eWebEditor.document.selection.createRange();
		sRangeType = dialogArguments.eWebEditor.document.selection.type;
		if (sRangeType == "Control") {
			oControl = GetControl(oSelection, "TABLE");
		}else{
			oControl = GetParent(oSelection.parentElement());
		}
		if (oControl) {
			switch(oControl.tagName){
			case "TD":
				sTitle += " - " + lang["DlgComTableCell"];
				break;
			case "TR":
			case "TH":
				sTitle += " - " + lang["DlgComTableRow"];
				break;
			default:
				sTitle += " - " + lang["DlgComTable"];
				break;
			}
			color = oControl.style.backgroundColor;
		}else{
			sTitle += " - " + lang["DlgComBody"];
		}
		break;
	default:
		if (URLParams['color']){
			color = decodeURIComponent(URLParams['color']) ;
		}
		break;
}

document.write("<TITLE>" + lang["DlgSelCor"] + "(" + sTitle + ")</TITLE>");

if (!color) color = "#000000";


function GetParent(obj){
	while(obj!=null && obj.tagName!="TD" && obj.tagName!="TR" && obj.tagName!="TH" && obj.tagName!="TABLE")
		obj=obj.parentElement;
	return obj;
}

function GetControl(obj, sTag){
	obj=obj.item(0);
	if (obj.tagName==sTag){
		return obj;
	}
	return null;
}

function N2Color(s_Color){
	s_Color = s_Color.toString(16);
	switch (s_Color.length) {
	case 1:
		s_Color = "0" + s_Color + "0000"; 
		break;
	case 2:
		s_Color = s_Color + "0000";
		break;
	case 3:
		s_Color = s_Color.substring(1,3) + "0" + s_Color.substring(0,1) + "00" ;
		break;
	case 4:
		s_Color = s_Color.substring(2,4) + s_Color.substring(0,2) + "00" ;
		break;
	case 5:
		s_Color = s_Color.substring(3,5) + s_Color.substring(1,3) + "0" + s_Color.substring(0,1) ;
		break;
	case 6:
		s_Color = s_Color.substring(4,6) + s_Color.substring(2,4) + s_Color.substring(0,2) ;
		break;
	default:
		s_Color = "";
	}
	return '#' + s_Color;
}

function InitDocument(){
	lang.TranslatePage(document);
	ShowColor.bgColor = color;
	RGB.innerHTML = color;
	SelColor.value = color;

	var s_BoxID = "cbox_" + color.substr(1);
	var o_Box = document.all(s_BoxID);
	if (o_Box){
		BoxClick(o_Box);
	}

	adjustDialog();
}


var SelRGB = color;
var DrRGB = '';
var SelGRAY = '120';

var hexch = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');

function ToHex(n) {	
	var h, l;

	n = Math.round(n);
	l = n % 16;
	h = Math.floor((n / 16)) % 16;
	return (hexch[h] + hexch[l]);
}

function DoColor(c, l){
	var r, g, b;

	r = '0x' + c.substring(1, 3);
	g = '0x' + c.substring(3, 5);
	b = '0x' + c.substring(5, 7);

	if(l > 120){
		l = l - 120;

		r = (r * (120 - l) + 255 * l) / 120;
		g = (g * (120 - l) + 255 * l) / 120;
		b = (b * (120 - l) + 255 * l) / 120;
	}else{
		r = (r * l) / 120;
		g = (g * l) / 120;
		b = (b * l) / 120;
	}

	return '#' + ToHex(r) + ToHex(g) + ToHex(b);
}

function EndColor(){
	var i;

	if(DrRGB != SelRGB){
		DrRGB = SelRGB;
		for(i = 0; i <= 30; i ++)
		GrayTable.rows(i).bgColor = DoColor(SelRGB, 240 - i * 8);
	}

	var s_Color = DoColor(RGB.innerText, GRAY.innerText);
	SelColor.value = s_Color
	ShowColor.bgColor = s_Color;

	var s_BoxID = "cbox_" + s_Color.substr(1);
	var o_Box = document.all(s_BoxID);
	if (o_Box){
		BoxClick(o_Box, true);
	}else{
		if (s_CurrBoxID){
			document.all(s_CurrBoxID).className = "boxNormal";
			s_CurrBoxID = ""
		}
	}

}

var s_CurrBoxID = "";
function BoxMouseOut(obj){
	if (obj.id==s_CurrBoxID){
		obj.className = "boxSelected";
	}else{
		obj.className = "boxNormal";
	}
}

function BoxMouseOver(obj){
	if (obj.id==s_CurrBoxID){
		obj.className = "boxSelected";
	}else{
		obj.className = "boxOver";
	}
}

function BoxClick(obj, notSel){
	if (obj.id==s_CurrBoxID){
		return;
	}else{
		if (s_CurrBoxID){
			document.all(s_CurrBoxID).className = "boxNormal";
		}

		s_CurrBoxID = obj.id;
		obj.className = "boxSelected";

		var s_Color = "#" + s_CurrBoxID.substr(5);
		if (!notSel){
			SelRGB = s_Color;
		}		
		SelColor.value = s_Color;
		ShowColor.bgColor = SelColor.value;

	}
}

</script>

<script event=onclick for=ColorTable type="text/javascript">
	SelRGB = event.srcElement.bgColor;
	EndColor();
</script>

<script event=onmouseover for=ColorTable type="text/javascript">
	RGB.innerText = event.srcElement.bgColor;
	EndColor();
</script>

<script event=onmouseout for=ColorTable type="text/javascript">
	RGB.innerText = SelRGB;
	EndColor();
</script>

<script event=onclick for=GrayTable type="text/javascript">
	SelGRAY = event.srcElement.title;
	EndColor();
</script>

<script event=onmouseover for=GrayTable type="text/javascript">
	GRAY.innerText = event.srcElement.title;
	EndColor();
</script>

<script event=onmouseout for=GrayTable type="text/javascript">
	GRAY.innerText = SelGRAY;
	EndColor();
</script>

<script event=onclick for=Ok type="text/javascript">
	color = SelColor.value;
	if (!IsColor(color)){
		alert(lang["ErrColorInvalid"]);
		return;
	}

	switch (sAction) {
		case "forecolor":
			dialogArguments.formatFont('color', color) ;
			window.returnValue = null;
			break;
		case "backcolor":
			dialogArguments.format('BackColor', color) ;
			window.returnValue = null;
			break;
		case "bgcolor":
			if (oControl){
				oControl.style.backgroundColor = color;
			}else{
				dialogArguments.setHTML("<table border=0 cellpadding=0 cellspacing=0 width='100%' height='100%'><tr><td valign=top bgcolor='"+color+"'>"+dialogArguments.getHTML()+"</td></tr></table>", true);
			}
			window.returnValue = null;
			break;
		default:
			window.returnValue = color;
			break;
	}
	window.close();
</script>

<style>
.boxNormal {border:1px solid #d4d0c8}
.boxOver {border-width:1px;border-color:#ffffff #000000 #000000 #ffffff;border-style:solid}
.boxSelected {border-width:1px;border-color:#000000 #ffffff #ffffff #000000;border-style:inset}

</style>

</HEAD>

<BODY onload="InitDocument()">
<table border=0 cellpadding=0 cellspacing=5 id=tabDialogSize><tr><td>

<table border=0 cellpadding=0 cellspacing=0 align=center>
<tr valign=top>
<td>
	<table border=0 cellpadding=0 cellspacing=10><tr><td>
	<table id= border=0 cellpadding=3 cellspacing=0>
	<tr>
		<td id="cbox_000000" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#000000"></td>
		<td id="cbox_993300" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#993300"></td>
		<td id="cbox_333300" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#333300"></td>
		<td id="cbox_003300" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#003300"></td>
		<td id="cbox_003366" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#003366"></td>
	</tr>
	<tr>
		<td id="cbox_000080" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#000080"></td>
		<td id="cbox_333399" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#333399"></td>
		<td id="cbox_333333" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#333333"></td>
		<td id="cbox_800000" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#800000"></td>
		<td id="cbox_FF6600" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#FF6600"></td>
	</tr>
	<tr>
		<td id="cbox_808000" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#808000"></td>
		<td id="cbox_008000" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#008000"></td>
		<td id="cbox_008080" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#008080"></td>
		<td id="cbox_0000FF" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#0000FF"></td>
		<td id="cbox_666699" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#666699"></td>
	</tr>
	<tr>
		<td id="cbox_808080" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#808080"></td>
		<td id="cbox_FF0000" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#FF0000"></td>
		<td id="cbox_FF9900" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#FF9900"></td>
		<td id="cbox_99CC00" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#99CC00"></td>
		<td id="cbox_339966" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#339966"></td>
	</tr>
	<tr>
		<td id="cbox_33CCCC" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#33CCCC"></td>
		<td id="cbox_3366FF" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#3366FF"></td>
		<td id="cbox_800080" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#800080"></td>
		<td id="cbox_999999" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#999999"></td>
		<td id="cbox_FF00FF" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#FF00FF"></td>
	</tr>
	<tr>
		<td id="cbox_FFCC00" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#FFCC00"></td>
		<td id="cbox_FFFF00" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#FFFF00"></td>
		<td id="cbox_00FF00" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#00FF00"></td>
		<td id="cbox_00FFFF" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#00FFFF"></td>
		<td id="cbox_00CCFF" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#00CCFF"></td>
	</tr>
	<tr>
		<td id="cbox_993366" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#993366"></td>
		<td id="cbox_C0C0C0" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#C0C0C0"></td>
		<td id="cbox_FF99CC" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#FF99CC"></td>
		<td id="cbox_FFCC99" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#FFCC99"></td>
		<td id="cbox_FFFF99" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#FFFF99"></td>
	</tr>
	<tr>
		<td id="cbox_CCFFCC" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#CCFFCC"></td>
		<td id="cbox_CCFFFF" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#CCFFFF"></td>
		<td id="cbox_99CCFF" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#99CCFF"></td>
		<td id="cbox_CC99FF" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#CC99FF"></td>
		<td id="cbox_FFFFFF" onmouseover="BoxMouseOver(this)" onmouseout="BoxMouseOut(this)" onclick="BoxClick(this)" class="boxNormal"><img src="../sysimage/space.gif" width=16 height=16 style="border:1px solid gray;background-color:#FFFFFF"></td>
	</tr>
	</table>
	</td></tr></table>

</td>

<td>

	<TABLE border=0 cellPadding=0 cellSpacing=10 align=center>
	<TR>
		<TD>
		<TABLE border=0 cellPadding=0 cellSpacing=0 id=ColorTable style="CURSOR: hand">
		<script type="text/javascript">
		function wc(r, g, b, n){
			r = ((r * 16 + r) * 3 * (15 - n) + 0x80 * n) / 15;
			g = ((g * 16 + g) * 3 * (15 - n) + 0x80 * n) / 15;
			b = ((b * 16 + b) * 3 * (15 - n) + 0x80 * n) / 15;

			document.write('<TD BGCOLOR=#' + ToHex(r) + ToHex(g) + ToHex(b) + ' height=8 width=8></TD>');
		}

		var cnum = new Array(1, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 0);

		for(i = 0; i < 16; i ++){
			document.write('<TR>');
			for(j = 0; j < 30; j ++){
				n1 = j % 5;
				n2 = Math.floor(j / 5) * 3;
				n3 = n2 + 3;

				wc((cnum[n3] * n1 + cnum[n2] * (5 - n1)),
				(cnum[n3 + 1] * n1 + cnum[n2 + 1] * (5 - n1)),
				(cnum[n3 + 2] * n1 + cnum[n2 + 2] * (5 - n1)), i);
			}

			document.writeln('</TR>');
		}
		</script>

		</TABLE>
		</TD>

		<TD>
		<TABLE border=0 cellPadding=0 cellSpacing=0 id=GrayTable style="CURSOR: hand">
		<script type="text/javascript">
		for(i = 255; i >= 0; i -= 8.5)
		document.write('<TR BGCOLOR=#' + ToHex(i) + ToHex(i) + ToHex(i) + '><TD TITLE=' + Math.floor(i * 16 / 17) + ' height=4 width=20></TD></TR>');
		</script>

		</TABLE>
		</TD>
	</TR>
	</TABLE>


	<TABLE border=0 cellPadding=0 cellSpacing=10 align=center>
	<TR>
		<TD noWrap align=middle rowSpan=2><span lang=DlgSelCorSel></span>
		<TABLE border=1 cellPadding=0 cellSpacing=0 height=30 id=ShowColor width=40 bgcolor=""><TBODY><TR><TD></TD></TR></TBODY></TABLE>
		</TD>
		<TD noWrap rowSpan=2><span lang=DlgSelCorBase></span>: <SPAN id=RGB></SPAN><BR><span lang=DlgSelCorLight></span>: <SPAN id=GRAY>120</SPAN><BR><span lang=DlgSelCorCode></span>: <INPUT id=SelColor size=7 value=""></TD>
		<TD><input id=Ok type=submit class="dlgBtnCommon" lang=DlgBtnOK value=""></TD>
	</TR>
	<TR>
		<TD noWrap><input type=button class="dlgBtnCommon" onclick="window.close();" lang=DlgBtnCancel value=""></TD>
	</TR>
	</TABLE>

</td>
</tr></table>


</td></tr></table>
</BODY></HTML>